from datetime import datetime
import time
import calendar

today = datetime.today().date()
print(today)

# Python函数用一个元组装起来的9组数字处理时间:
localtime = time.localtime(time.time())
print(localtime)

# 格式化日期
localtime = time.asctime(time.localtime(time.time()))
print(localtime)

# 格式化日期
localtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
print('本地时间为:', localtime)

# 格式化日期
print(time.strftime('%b %B', time.localtime()))
print(time.strftime('%B', time.localtime()))
print(time.strftime('%b', time.localtime()))

date_str = '2024-08-28 13:12:26.886162'
date_obj = datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S.%f')
print(date_obj)

year = 2024
month = 8
print(calendar.month(year, month))

is_leap = calendar.isleap(2024)
print(is_leap)  # 输出: True
